package com.blb.zy_community.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.zy_community.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mysql.cj.log.Log;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 角色信息表 Mapper 接口
 * </p>
 *
 * @author 二组
 * @since 2023-06-18
 */
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {

    /**
     * 分页查询角色
     * @param page
     * @return
     */
    @Select("select * from sys_role")
    Page<SysRole> selectRolePage(Page<SysRole> page,String roleName,String roleKey,String roleStatus,String startTime,String endTime);

    /**
     * 根据角色ID数组，批量删除
     * @param roleIds
     */
    void deleteRoles(Long[] roleIds);

    /**
     * 假删除
     */
    @Update("update sys_role  set  del_flag = 2 where role_id = #{roleId}")
    void updateDelFlagId(Long roleId);

    /**
     * 修改角色状态
     */
    @Update("update sys_role set status = #{statusId} where role_id = #{roleId}")
    void updateStatus(Long statusId,Long roleId);

    /**
     * 判断是否用户重复
     */
    @Select("select * from sys_role where role_name = #{roleName}")
    SysRole checkName(String roleName);


    void selectRoleName(Long id);
//    void selectRoleName();

    /**
     * 通过用户id查询用户角色
     * @param userId
     * @return
     */
    List<SysRole> selectByUserId(Long userId);
}
